<template>

  <el-popover :width="225" placement="right" trigger="click" popper-class="popover">
    <template #reference>
      <div class="addNodeBtn">
        <Plus size="1em" class="plusIcon" style="width: 1em; height: 1em; margin-right: 8px"/>
      </div>
    </template>
    <!-- 添加审核人-抄送人-条件的popover弹窗 -->
    <div class="initiatorOrReviewer">
      <div class="checkInitiator" @click="onAddNode(1)">
        <div class="addNodeBtn" style="background-color: #FF943E">
          <Avatar size="1em" class="plusIcon" style="width: 1em; height: 1em; margin-right: 8px"/>
        </div>
        <div style="margin-top: 10px">审核人</div>
      </div>

      <div class="checkInitiator" @click="onAddNode(2)">
        <div class="addNodeBtn" style="background-color: #3296fa">
          <Promotion size="1em" class="plusIcon" style="width: 1em; height: 1em; margin-right: 8px"/>
        </div>
        <div style="margin-top: 10px">抄送人</div>
      </div>

      <div class="checkInitiator" @click="onAddNode(3)">
        <div class="addNodeBtn" style="background-color: #15BC83">
          <EditPen size="1em" class="plusIcon" style="width: 1em; height: 1em; margin-right: 8px"/>
        </div>
        <div style="margin-top: 10px">条件</div>
      </div>
    </div>
  </el-popover>


</template>
<script setup lang="ts">
import {Avatar, EditPen, Plus, Promotion} from "@element-plus/icons-vue";
import {ElMessage} from "element-plus";
import {nanoid} from "nanoid";

const props = defineProps(['nodeData']);
const $emits = defineEmits(["setNodeData"]);
const onAddNode = (type) => {
  if (type === 1) {
    $emits('setNodeData', {
      nodeName: '审核人',
      id: nanoid()
    })
  } else if (type === 2) {
    $emits('setNodeData', {
      nodeName: '抄送人',
      id: nanoid()
    })
  } else if (type === 3) {
    $emits('setNodeData', {
      nodeName: '审核人',
      id: nanoid()
    })
  } else {
    ElMessage.error('错误')
  }
}

</script>

<style scoped>
.initiatorOrReviewer {
  display: flex;
  align-items: center;
  justify-content: space-between;

  .checkInitiator {
    width: 60px;
    padding: 5px;
    height: 100%;
    display: flex;
    align-items: center;
    flex-direction: column;

    .addNodeBtn {
      width: 45px;
      height: 45px;
      border-radius: 50%;
      position: relative;
      display: flex;
      align-items: center;
      flex-direction: column;

      .plusIcon {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: white;
      }
    }
  }

  .checkInitiator:hover {
    background-color: #C1ECE7;
  }

}
</style>
